package cn.sample.moreitems.screen;

import cn.sample.moreitems.MoreItems;
import cn.sample.moreitems.menu.TechnologyMenu;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class TechnologyScreen extends AbstractContainerScreen<TechnologyMenu> {
    private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(MoreItems.MODID, "textures/gui/container/furnace.png");

    public TechnologyScreen(TechnologyMenu m, Inventory inv, Component t) { super(m, inv, t); }

    @Override
    public void render(GuiGraphics gfx, int mx, int my, float pt) {
        renderBackground(gfx);
        renderBg(gfx, pt, mx, my);
        super.render(gfx, mx, my, pt);
        renderTooltip(gfx, mx, my);
    }

    @Override
    protected void renderBg(GuiGraphics gfx, float pt, int mx, int my) {
        int x = (width - imageWidth) / 2, y = (height - imageHeight) / 2;
        gfx.blit(TEXTURE, x, y, 0, 0, imageWidth, imageHeight);
        /* 火焰 */
        int burn = menu.getPrice();
        if (burn > 0) gfx.blit(TEXTURE, x + 56, y + 36 + 12 - burn, 176, 12 - burn, 14, burn + 1);
        /* 箭头 */
        int cook = menu.getPrice2();
        gfx.blit(TEXTURE, x + 79, y + 34, 176, 14, cook + 1, 16);
    }

}
